package part01_七大原则.p03_依赖倒转原则.依赖关系传递的三种方式;

/**
 * @ClassName: DependencyPass01
 * @Author: AllenSun
 * @Date: 2019/12/2 23:44
 */
public class DependencyPass01 {
    public static void main(String[] args) {
        ChangHong01 changHong = new ChangHong01();
        OpenAndClose01 openAndClose = new OpenAndClose01();
        openAndClose.open(changHong);
    }
}

//通过接口传递实现依赖
//开关的接口（依赖电视的接口）
interface IOpenAndClose01{
    public void open(ITV01 tv);
}

//电视的接口
interface ITV01{
    public void play();
}

//电视的实现类
class ChangHong01 implements ITV01{

    @Override
    public void play() {
        System.out.println("长虹电视，打开");
    }
}

//电视开关的实现类
class OpenAndClose01 implements IOpenAndClose01{

    @Override
    public void open(ITV01 tv) {
        tv.play();
    }
}